﻿using System;
using System.Collections.Generic;
using System.Text;

namespace SumofTwoIntegers
{
    public class Solution
    {
        public int GetSum(int a, int b)
        {
            int sum, carry;
            while (b != 0)
            {
                // sum是和，而carry是进位，
                // sum表示计算的①，carry表示计算的②，
                // 不断地进行①与②，直到②为0
                sum = a ^ b;
                carry = (a & b) << 1;
                a = sum;
                b = carry;
            }
            return a;
        }
    }
}
